//management of the SDL

#include "out_gestionSDL.h"

SDL_Surface* initSDL(int largeur, int hauteur){
	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)==-1){
		fprintf(stderr, "Erreur d'initialisation de la SDL :\n%s\n", SDL_GetError());
		exit(EXIT_FAILURE);
	}

	atexit(SDL_Quit);

	//_putenv("SDL_VIDEO_WINDOW_POS=50,50");

	SDL_Surface *ecran = SDL_SetVideoMode(largeur, hauteur, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_NOFRAME);
	if(ecran == NULL){
		fprintf(stderr, "Erreur de chargement du mode video :\n%s\n", SDL_GetError());
		exit(EXIT_FAILURE);
	}


	SDL_WM_SetCaption("CoreWar", NULL);

	return ecran;

}



int gestion_evt(){
	SDL_Event event;

	SDL_PollEvent(&event);
	switch(event.type){
		//case SDL_QUIT:
		//	return 1;	//exit
		//	break;
		case SDL_KEYDOWN:
			switch(event.key.keysym.sym){
				case SDLK_ESCAPE:
					return 1;
					break;
                            default:
                                break;
			}
			break;
            default:
                break;
	}

	return 0;	//no event
}
